/*
 * =====================================================================================
 *
 *       Filename:  action.cc
 *
 *    Description:  implement methods in class Action
 *
 *        Version:  1.0
 *        Created:  2009年08月06日 15时52分51秒
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  Gestrom Drawn (mn), zhcfreesea@gmail.com
 *        Company:  zhc
 *
 * =====================================================================================
 */

#include"action.h"
#include<iostream>

Action::Action(): _current_action("sleep")
{
    _actions["eat"] = _action_eat;
    _actions["sleep"] = _action_sleep;
}

Action::Action(std::string action_): _current_action(action_)
{
    _actions["eat"] = _action_eat;
    _actions["sleep"] = _action_sleep;
}
ActionResult Action::_action_eat()
{
    std::cout << "do action eat" << std::endl;
    return SUCCESS;
}
ActionResult Action::_action_sleep()
{
    std::cout << "do action sleep" << std::endl;
    return SUCCESS;
}
ActionResult Action::operator=(std::string action_)
{
    _current_action = action_;
    return _actions[action_]();
}
bool Action::operator==(Action action_)
{
    return _current_action == action_._current_action;
}
bool Action::operator==(std::string action_name_)
{
    return _current_action == action_name_;
}
std::string Action::_get_current_action()
{
    return _current_action;
}
